<?= $ProductController->GetBreadcrumb() ?>
<div class="main_product">
    <div class="product_detail_featured">
        <div class="product_detail_img">
            <img src="<?= $ProductController->GetProductThumb() ?>" alt="<?= $ProductController->name ?>"/>
        </div>
        <!-- End product_detail_img -->
        <div class="product_detail_info">
            <h1><?= $ProductController->name ?></h1>

            <div class="product_detail_social">

            </div>
            <div class="product_detail_info_main">
                <table>
                    <tr>
                        <td>Giá bán:</td>
                        <? $price = $ProductController->get('pro_price');?>
                        <td class="red"><?=($price == 68000000 ? 'Liên hệ' : format_price($price))?></td>
                    </tr>
                    <tr>
                        <td>Thông tin cơ bản:</td>
                        <td><?= nl2br($ProductController->get('pro_basic_info')) ?></td>
                    </tr>
                    <tr>
                        <td>Bảo hành:</td>
                        <td><?= $ProductController->get('pro_warranty') ?></td>
                    </tr>
                    <tr>
                        <td>Trạng thái:</td>
                        <td><?= $global_product_status_in_stock[$ProductController->get('pro_status_in_stock')] ?></td>
                    </tr>
                    <tr>
                        <td>Khuyến mại</td>
                        <td><?= nl2br($ProductController->get('pro_promotion')) ?></td>
                    </tr>
                </table>
            </div>
        </div>
        <!-- End product_detail_info -->
        <div class="product_detail_add_card">
            <form method="post" action="<?= generate_shop_cart_list() ?>" id="a2c-form" ajax-action="/ajax/addToCart">
                <input type="hidden" name="pro[id]" value="<?= $ProductController->getId() ?>">
                <label>Số lượng</label>
                <select name="pro[number]">
                    <option value="1"> 1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                </select>
                <a class="product_detail_add_card_btn btn_add_cart"><span>Thêm vào giỏ</span></a>
            </form>
        </div>
        <!-- End product_detail_add_card -->
    </div>
    <!-- End product_detail_featured -->
    <div class="product_detail_main">
        <div class="product_detail_main_tab">
            <ul>
                <li><a class="tab-hinh-anh active" href="#hinh-anh">Hình ảnh</a></li>
                <li><a class="tab-bai-viet-san-pham" href="#bai-viet-san-pham">Bài viết sản phẩm</a></li>
                <li><a class="tab-thong-so-ky-thuat" href="#thong-so-ky-thuat">Thông số kỹ thuật</a></li>
                <li><a class="tab-video-san-pham" href="#video-san-pham">Video sản phẩm</a></li>
                <li><a class="tab-cac-phu-kien" href="#cac-phu-kien">Các phụ kiện</a></li>
                <li><a class="tab-san-pham-tuong-tu" href="#san-pham-tuong-tu">Sản phẩm tương tự</a></li>
            </ul>
        </div>
        <!-- End product_detail_main_tab -->
        <div class="product_detail_main_info">
            <script type="text/javascript">
                $(window).load(function () {
                    $("#slider_pro").nivoSlider();
                });
            </script>
            <?= $ProductController->GetProductDetailSlide() ?>
            <script>
                $('.product_detail_main_tab').scrollToFixed();
            </script>
            <?
            $baiviet_dt = $ProductController->get('pro_detail');
            if($baiviet_dt){
                ?>
                <div class="product_detail_group" id="bai-viet-san-pham">
                    <div class="product_detail_group_tab">
                        <h3>Bài viết sản phẩm</h3>
                    </div>
                    <div class="product_detail_group_main product_detail_baiviet" style="padding: 10px;">
                        <?=$baiviet_dt?>
                    </div>
                </div>
            <?
            }
            ?>
            <? //Layout bảng thông số kỹ thuật ?>
            <?= $ProductController->GetProductSpec($ProInfo) ?>
            <? //video sản phẩm?>
            <?= $ProductController->GetYoutubeVideo($ProductController->get('pro_video')) ?>
            <? //end video sản phẩm?>

            <? //Các phụ kiện?>
            <?= $ProductController->getProductCombo() ?>
            <? //end các phụ kiện?>

            <? //các sản phẩm liên quan?>
            <?= $ProductController->getProductRelation() ?>
            <? //end các sản phẩm liên quan?>
        </div>
    </div>
    <!-- End product_detail_main -->
</div><!-- End main_product -->
<script>
    $(document).ready(function () {
        var hinhanh = 0;
        var baivietsanpham = 0;
        var thongsokythuat = 0;
        var videosanpham = 0;
        var cacphukien = 0;
        var sanphamtuongtu = 0;
        if ($('#hinh-anh').length == 1) {
            hinhanh = $('#hinh-anh').offset().top - 100;
        }
        if ($('#bai-viet-san-pham').length == 1) {
            baivietsanpham = $('#bai-viet-san-pham').offset().top - 100;
        }
        if ($('#thong-so-ky-thuat').length == 1) {
            thongsokythuat = $('#thong-so-ky-thuat').offset().top - 100;
        } else {
            thongsokythuat = hinhanh + 500;
        }
        if ($('#video-san-pham').length == 1) {
            videosanpham = $('#video-san-pham').offset().top - 100;
        } else {
            videosanpham = thongsokythuat + 700;
        }
        if ($('#cac-phu-kien').length == 1) {
            cacphukien = $('#cac-phu-kien').offset().top - 100;
        } else {
            cacphukien = videosanpham + 100;
        }
        if ($('#san-pham-tuong-tu').length == 1) {
            sanphamtuongtu = $('#san-pham-tuong-tu').offset().top - 100;
        } else {
            sanphamtuongtu = cacphukien + 200;
        }
        var footer = $('.top_footer').offset().top;
        //console.log(hinhanh);
        //console.log(thongsokythuat);
        $(window).scroll(function () {
            var scr = $(window).scrollTop();
            console.log(scr);
            if ($('#hinh-anh').length == 1 && scr >= hinhanh && scr < baivietsanpham) {
                $('.product_detail_main_tab ul li a').removeClass('active');
                $('.tab-hinh-anh').addClass('active');
            }
            if ($('#bai-viet-san-pham').length == 1 && scr >= baivietsanpham && scr < thongsokythuat) {
                $('.product_detail_main_tab ul li a').removeClass('active');
                $('.tab-bai-viet-san-pham').addClass('active');
            }
            if ($('#thong-so-ky-thuat').length == 1 && scr >= thongsokythuat && scr < videosanpham) {
                $('.product_detail_main_tab ul li a').removeClass('active');
                $('.tab-thong-so-ky-thuat').addClass('active');
            }
            if ($('#video-san-pham').length == 1 && scr >= videosanpham && scr < cacphukien) {
                $('.product_detail_main_tab ul li a').removeClass('active');
                $('.tab-video-san-pham').addClass('active');
            }
            if ($('#cac-phu-kien').length == 1 && scr >= cacphukien && scr < sanphamtuongtu) {
                $('.product_detail_main_tab ul li a').removeClass('active');
                $('.tab-cac-phu-kien').addClass('active');
            }
            if ($('#san-pham-tuong-tu').length == 1 && scr >= sanphamtuongtu && scr < footer) {
                $('.product_detail_main_tab ul li a').removeClass('active');
                $('.tab-san-pham-tuong-tu').addClass('active');
            }
        });
    });
</script>